package com.huai.demo_test1.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.client.RestTemplate;

import java.nio.charset.StandardCharsets;

/**
 * @author 淮晓欢
 * @date 2021/12/28
 **/
@Configuration
public class RestTemplateConfig {
    /**
     * 创建RestTemplate对象
    */
    @Bean
    public RestTemplate restTemplate(){
        RestTemplate template=new RestTemplate();
        template.getMessageConverters().set(1,new StringHttpMessageConverter(StandardCharsets.UTF_8));
        return template;
    }

}
